package com.legendframework.core.cmd.paramer.converter.impl;

import com.legendframework.core.ioc.IParameter;
import com.legendframework.core.ioc.annotation.Component;
import com.legendframework.core.cmd.paramer.converter.ParamerConverter;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;

@Component
public class OfflinePlayerParamerConverter implements ParamerConverter<OfflinePlayer> {

    @Override
    public boolean check(Class<?> cls) {
        return OfflinePlayer.class == cls;
    }

    @Override
    public OfflinePlayer castParameter(CommandSender sender, String message, Class<OfflinePlayer> type, IParameter parameter) {
        return Bukkit.getOfflinePlayer(message);
    }
}
